package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsGoodsSpecificationMapper;
import com.qf.pojo.DtsGoodsSpecification;
import com.qf.service.DtsGoodsSpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author 千峰教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */
@Service
public class DtsGoodsSpecificationServiceImpl implements DtsGoodsSpecificationService {

    @Autowired
    DtsGoodsSpecificationMapper specificationMapper;

    @Override
    public List<DtsGoodsSpecification> findGoodsSpecification(Integer id) {

        LambdaQueryWrapper<DtsGoodsSpecification> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsSpecification::getDeleted, false);
        wrapper.eq(DtsGoodsSpecification::getGoodsId, id);


        return specificationMapper.selectList(wrapper);
    }

    @Override
    public void deleteByGid(Integer id) {
        LambdaQueryWrapper<DtsGoodsSpecification> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsSpecification::getGoodsId, id);

        specificationMapper.delete(wrapper);
    }

    @Override
    public void insert(DtsGoodsSpecification specification) {

        specification.setAddTime(new Date());
        specification.setUpdateTime(new Date());
        specification.setDeleted(false);
        specificationMapper.insert(specification);
    }
}
